<?php

namespace app\models;

use yii\base\Model;
use yii\web\UploadedFile;

class UploadForm extends Model
{
    public $pdfFile;
    public $filename;

    public function rules()
    {
        return [
        	[['filename'], 'required'],
            [['pdfFile'], 'file', 'skipOnEmpty' => false, 'extensions' => 'pdf'],
        ];
    }
    
    public function upload()
    {
        if ($this->validate()) {

            $this->pdfFile->saveAs('../web/upload/pdf/' . $this->filename . '.pdf');
            return true;
        } else {

            return false;
        }
    }
}

?>